/**
 * Created by xingkaihang on 2017/5/24.
 */
import React, { Component } from 'react'
import {showImg} from '../../../utils/images'
import { Row, Col, Spin, Button, DatePicker } from 'antd';
import Loading from '../public/loading'
import './white.scss'

const handleClickDetail = (data) => () => {
    console.log('data:', data)
}

export default class white extends Component {

    constructor(porps) {
        super(porps);
    }
    handleChangeSearchDate(value,dateString) {
        console.log('...',value)
        console.log('...',dateString)
    }

    disabledDate(current) {
        // can not select days before today and today
        return current && current.valueOf() > Date.now();
    }

    componentWillMount() {
        const { emptyData } = this.props;
        //清空原有的数据
        emptyData()
    }

    render() {
        const { list, emptyData } = this.props;
        const listView = list.stories.length > 0 ?
            list.stories.map((e, index)=>
                <div className="white-li" key={index} onClick={handleClickDetail(e)}>
                    <span className="white-li-img" dangerouslySetInnerHTML={{__html: showImg(e.images)}}/>
                    <div className="white-li-right">
                        {e.title}
                    </div>
                </div>
            ) : <Loading/>;
        return (
            <div className='white-wrapper'>
                <div className="white-nav">
                    <DatePicker disabledDate={this.disabledDate} onChange={this.handleChangeSearchDate.bind(this)}/>
                    <Button className='fr' onClick={() => emptyData()}>清除数据</Button>
                </div>
                <div className="list-part">
                    {listView}
                </div>
            </div>
        )
    }

    componentDidMount() {
        const { defaultFetchData } = this.props;
        //默认调取数据
        defaultFetchData()
    }
}